<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script>
        class Person {
        // 构造函数使用 constructor 关键字作为名称
        constructor(name, age) {
            this.name = name;
            this.age = age;
        }
        }
        // 让 Student 继承 Person
        class Student extends Person {
            constructor(name, age, hobby) {
                // 子类必须在 constructor 方法中调用 super 方法，否则新建实例时会报错。
                super(name, age);
                this.hobby = hobby;
            }
            // 定义成员方法
            show() {
                alert("我是： " + this.name + "，我的爱好是： " + this.hobby);
            }
        }
        let stu = new Student("张三", 18, "打球");
        console.log("stu.name =",stu.name);// 张三
        console.log(stu);
        console.log("stu instanceof Student", stu instanceof Student);//true
        console.log("stu instanceof Person", stu instanceof Person);//true
        console.log("stu instanceof Object", stu instanceof Object);//true
    </script>
</head>
<body>
    
</body>
</html>